<!-- 编辑学校 -->
<template>
  <div class="page-box h100 display-flex czbj">
    <!-- <p class="title-label mb10">基本信息</p> -->
    <div class="pr20">
      <div class="xcxretr4xrt">
        <div class="display-flex mt20">
          <div class="xcxcdsrey vertical-center tr">学校所在区域:</div>
          <div class="flex-1">
            {{ dmxcxzdf(formData.qyId) }}
          </div>
        </div>

        <div class="display-flex mt20">
          <div class="xcxcdsrey vertical-center tr">学校名称:</div>
          <div class="flex-1">
            {{ formData.title }}
            <!-- <n-input
              v-model:value="formData.title"
              type="text"
              placeholder="请输入学校名称"
            /> -->
          </div>
        </div>
        <div class="display-flex mt20">
          <div class="xcxcdsrey vertical-center tr">负责人电话:</div>
          <div class="flex-1">
            {{ formData.phone }}
            <!-- <n-input
              v-model:value="formData.phone"
              type="text"
              placeholder="请输入学校名称"
            /> -->
          </div>
        </div>
        <div class="display-flex mt20">
          <div class="xcxcdsrey vertical-center tr">负责人姓名:</div>
          <div class="flex-1">
            <n-input
              v-model:value="formData.name"
              type="text"
              placeholder="请输入学校名称"
            />
          </div>
        </div>
        <div class="display-flex mt20">
          <div class="xcxcdsrey tr">登录密码:</div>
          <div class="flex-1">
            <n-input
              v-model:value="formData.paw"
              type="text"
              placeholder="请输入登录密码"
            />
          </div>
        </div>
        <!-- <div class="display-flex mt20">
          <div class="xcxcdsrey vertical-center tr">收费标准:</div>
          <div class="flex-1">
            <n-input
              v-model:value="formData.sfbz"
              type="text"
              placeholder="请输入收费标准"
            />
          </div>
        </div> -->
        <div class="display-flex mt20">
          <div class="xcxcdsrey tr">学校地址:</div>
          <div class="flex-1">
            <span class="ls sz" @click="ismaps = true">
              {{ formData.adds || "点击选择地址" }}
            </span>

            <div class="mt20">
              <n-button type="primary" @click="baocunsdr" class="xcxzcdstt">
                保存
              </n-button>
              <!-- <n-button
                type="primary"
                @click="showModal = true"
                class="xcxzcdstt ml20"
              >
                课程报名二维码
              </n-button> -->

              <n-popconfirm @positive-click="tuichusdr">
                <template #trigger>
                  <n-button type="error" class="xcxzcdstt ml20">
                    退出登录
                  </n-button>
                </template>
                确认退出登录吗？
              </n-popconfirm>
            </div>
          </div>
        </div>
      </div>
    </div>

    <n-modal v-model:show="ismaps" preset="card" class="kzxcxdffrtret">
      <template #header>
        <div>选择地址</div>
      </template>
      <div class="w100 h100">
        <dxmap @close="ismaps = false" @success="successmap"></dxmap>
      </div>
    </n-modal>

    <n-modal v-model:show="showModal" preset="card" class="xcxctrxr">
      <template #header>
        <div>学校课程二维码</div>
      </template>
      <div class="cen">
        <img
          src="https://duxinggj.com/public/QRcode/imgqr?text=hdbm2"
          class="xcxctrext"
        />
      </div>
      <template #action>
        <div class="tr">
          <n-button @click="showModal = false"> 关闭 </n-button>
        </div>
      </template>
    </n-modal>
  </div>
</template>
<script lang="ts" setup>
import { ref } from "vue";
import dxmap from "../../../components/util/dxmap.vue";
import { dxget, dxpost, hf } from "../../../util/index";
const xmlxSelect = ref([]);
const ismaps = ref(false);
const formData = ref({});
const xxid = localStorage.xxid;
if (!xxid) {
  hf("cloading");
}
const showModal = ref(false);
const successmap = (data) => {
  formData.value.adds = data.dikjxzx;
  ismaps.value = false;
};
// 获取字典内容
const xtgxxmfl = async () => {
  const { data }: any = await dxget("dxgjAdmin/getzd", { name: "dzkhqy" });
  xmlxSelect.value = data;
  console.log(data);
};

const initdata = async () => {
  await xtgxxmfl();
  const { data }: any = await dxget("courseManagement/schoolManagement", {
    id: xxid,
  });
  formData.value = data;
};
initdata();

const dmxcxzdf = (data) => {
  try {
    return xmlxSelect.value.filter((a) => a.value == data)[0].label;
  } catch (e) {
    return "-";
  }
};
const baocunsdr = async () => {
  const { data }: any = await dxpost(
    "courseManagement/schoolManagement",
    formData.value,
    "put"
  );
  window.$message.success("保存成功");
};
const tuichusdr = (data) => {
  console.log(data);
  localStorage.removeItem("xxid");
  hf("cloading");
};
</script>
<style scoped>
.xcxcdsrey {
  width: 120px;
  text-align: right;
  padding-right: 10px;
}
.xcxretr4xrt {
  width: 600px;
}
.xcxzcdstt {
  min-width: 100px;
  font-size: 18px;
}
</style>
